/*
 *  Copyright (c) 2022 ZhuHai Jieli Technology Co.,Ltd.
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

#ifndef _LRC_HW_H_
#define _LRC_HW_H_

#include "typedef.h"

#define LRC_Hz_DEFAULT    (32 * 1000L)

#define LRCT_TS(x)        SFR(JL_LRCT->CON,  1,  5,  x)

#define SAMPLE_POINT      40

struct lrc_driver_hdl {
    u8 enable;
    u8 cnt;
    u8 timer;
    u8 sample_point;
    u8 sample_cnt;
    u32 lrc_hz;
    u32 avg_lrc_hz;
    u32 fifo_arr[SAMPLE_POINT];
};

/*-----------------------------------------------------------*/

void __hw_lrc_enable(u8 en);

void __hw_lrc_init(void);

void __hw_lrc_set_param(u8 a, u8 b);

u32 __get_lrc_hz(void);

bool __lrc_trace_ready(void);

#endif
